package com.buaa.divinationmaster.test.utils;

import com.buaa.divinationmaster.feature.tarot.data.repository.TarotRepository;

import java.lang.reflect.Field;

/**
 * Repository测试辅助工具
 * 用于在测试环境中重置单例实例
 */
public class RepositoryTestHelper {

    /**
     * 重置TarotRepository单例实例，确保每个测试独立运行
     */
    public static void resetTarotRepositorySingleton() {
        try {
            Field instanceField = TarotRepository.class.getDeclaredField("instance");
            instanceField.setAccessible(true);
            instanceField.set(null, null);
        } catch (Exception e) {
            // 如果无法重置，记录错误但不影响测试
            System.err.println("Warning: Could not reset TarotRepository singleton: " + e.getMessage());
        }
    }
}
